<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('商户会员详细')" />
	<th:block th:include="include :: jsonview-css" />
</head>
<body class="white-bg">

	<div class="main-content">
        <form id="form-detail" class="form-horizontal" th:object="${optShopMember}">
            <input name="id" th:field="*{id}" type="hidden">
            <h4 class="form-header h4">客户信息</h4>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">所属组织：</label>
                        <div class="col-sm-8">
							<input class="form-control" type="text" th:field="*{deptName}" disabled>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">会员卡号：</label>
                        <div class="col-sm-8">
                            <input class="form-control" type="text" id="memberCardNumber" th:field="*{memberCardNumber}" readonly>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">客户名称：</label>
                        <div class="col-sm-8">
                            <div class="form-control" th:text="*{userName}" disabled></div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">账户余额：</label>
                        <div class="col-sm-8">
                            <div class="form-control" id="balance" th:text="*{balance}" disabled></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">手机号码：</label>
                        <div class="col-sm-8">
                            <input class="form-control" type="text" th:field="*{mobile}" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">充值余额：</label>
                        <div class="col-sm-8">
                            <div class="form-control" id="principalBalance" th:text="*{principalBalance}" disabled></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">用户性别：</label>
                        <div class="col-sm-8">
                            <select name="gender" disabled readonly class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                                        th:field="*{gender}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">活动余额：</label>
                        <div class="col-sm-8">
                            <div class="form-control" id="activityBalance" th:text="*{activityBalance}" disabled></div>

                        </div>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4" style="margin: 8px 10px">充值消费记录</h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="main-content  table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>


        </form>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="rechargePage()" shiro:hasPermission="operator:order:recharge">
                <i class="fa fa-plus"></i> 充值
            </a>
            <a class="btn btn-primary " onclick="expensePage()" shiro:hasPermission="operator:order:expense">
                <i class="fa fa-minus"></i> 消费
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="operator:order:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
    </div>


    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jsonview-js" />
    <script th:inline="javascript">

        var orderTypeDATA = [[${@dict.getType('t_order_type')}]];
        var prefix = ctx + "operator/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/recharge",
                detailUrl: prefix + "/expense",
                exportUrl: prefix + "/export",
                modalName: "会员收支记录",
                sortName: "createTime",
                sortOrder: "desc",
                columns: [
                    {
                        field: 'orderId',
                        title: '订单编号'
                    },
                    {
                        field: 'deptName',
                        title: '部门名称'
                    },
                    {
                        field: 'userName',
                        title: '姓名'
                    },
                    {
                        field: 'mobile',
                        title: '手机号'
                    },
                    {
                        field: 'memberCardNumber',
                        title: '会员卡号'
                    },
                    {
                        field: 'behalfType',
                        title: '类型',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(orderTypeDATA, value);
                        }
                    },
                    {
                        field: 'consumeAmount',
                        title: '金额'
                    },
                    {
                        field: 'balance',
                        title: '账户余额'
                    }
                ]
            };
            $.table.init(options);
        });

        function expensePage() {
            $.modal.open("会员消费",  prefix + "/expense/" + $('#memberCardNumber').val());
        }

        function rechargePage() {
            $.modal.open("会员充值",  prefix + "/recharge/" + $('#memberCardNumber').val());
        }

        function reload() {
            $.post(ctx + 'operator/member/balance', {
                "memberCardNumber": $("#memberCardNumber").val()
            }, function(result) {
                if ($.common.isNotEmpty(result)){
                    $("#balance").html(result.balance)
                    $("#principalBalance").html(result.principalBalance)
                    $("#activityBalance").html(result.activityBalance)
                }
            });
        }

    </script>
</body>
</html>
